package com.examples;

import java.util.Collection;

import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.SVNURL;
import org.tmatesoft.svn.core.auth.ISVNAuthenticationManager;
import org.tmatesoft.svn.core.internal.io.fs.FSRepositoryFactory;
import org.tmatesoft.svn.core.io.SVNFileRevision;
import org.tmatesoft.svn.core.io.SVNRepository;
import org.tmatesoft.svn.core.io.SVNRepositoryFactory;
import org.tmatesoft.svn.core.wc.SVNWCUtil;

public class FileRevisions {

	public static void main(String[] args) {
		try {
			String url = "file:///d:/Repositorios/svnkit";
			String login = "anonymous";
			String password = "anonymous";

			FSRepositoryFactory.setup();
			SVNRepository repository = SVNRepositoryFactory.create(SVNURL.parseURIDecoded(url));

			ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager(login, password);
			repository.setAuthenticationManager(authManager);

			long startRevision = 0;
			long endRevision = 1242;

			String path = "/trunk/javasvn/src/org/tigris/subversion/javahl/SVNClient.java";
			Collection<?> fileRevisions = repository.getFileRevisions(path, null, startRevision, endRevision);
			for (Object object : fileRevisions) {
				SVNFileRevision revision = (SVNFileRevision) object;
				System.out.println(revision.getRevision() + " " + revision.getPath());
			}
		} catch (SVNException e) {
			e.printStackTrace();
		}
	}
}
